<?php

class Empeval_Methods_Response_GetMyBonusGoals {
	
	/**
	 *
	 * @var Empeval_Methods_Data_ResponseStatus
	 */
	public $responseStatus;
	
	/**
	 *
	 * @var Empeval_Methods_Data_BonusGoalsFormGroup[]
	 */
	public $formGroups = array();
	
	/**
	 * 
	 * @var Empeval_Methods_Data_BonusPeriod[]
	 */
	public $bonusPeriods = array();
	
	public function __construct($status, $bgfs, $bonusPeriods) {
		$this->responseStatus = new Empeval_Methods_Data_ResponseStatus($status);
		$formGroups = array();
		foreach ($bgfs as $bgf) {
			$key = ($bgf->getStatus() === EmpevalBonusGoalsForms::STATUS_CLOSED) ? $bgf->getYear() : 9999;
			$formGroups[$key][] = new Empeval_Methods_Data_BaseBonusGoalsForm($bgf);
		}
		ksort($formGroups);
		$formGroups = array_reverse($formGroups, true);
		foreach ($formGroups as $year => $forms) {
			$formGroup = new Empeval_Methods_Data_BonusGoalsFormGroup($year);
			foreach ($forms as $form) {
				$formGroup->addForm($form);
			}
			$this->formGroups[] = $formGroup;
		}
		foreach ($bonusPeriods as $bonusPeriod) {
			$this->bonusPeriods[] = new Empeval_Methods_Data_BonusPeriod($bonusPeriod);
		}
	}
	
}